<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of masterrekening
 *
 * @author miyzan
 */
class datasiswa extends MY_Controller{
    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model("datasiswa_model","mds");
    }
    
    public function get_rows() {

        $page   =   ($this->input->post('page', TRUE) ? $this->input->post('page', TRUE) : 1);
        $start = isset($_POST['start']) ? $this->db->escape_str($this->input->post('start', TRUE)) : 0;
        $limit = isset($_POST['limit']) ? $this->db->escape_str($this->input->post('limit', TRUE)) : $this->config->item("length_records");
        $search = isset($_POST['query']) ? $this->db->escape_str($this->input->post('query', TRUE)) : '';

        $result = $this->mds->get_rows($search, $start, $limit);
        echo $result;
    }
    
    public function get_rows_combo() {

        $result = $this->mds->get_rows_combo();
        echo $result;
    }
    public function get_rows_all() {

        $result = $this->mds->get_rows_combo();
        echo $result;
    }
    
     public function get_rows_twin() {

        $page   =   ($this->input->post('page', TRUE) ? $this->input->post('page', TRUE) : 1);
        $start = isset($_POST['start']) ? $this->db->escape_str($this->input->post('start', TRUE)) : 0;
        $limit = isset($_POST['limit']) ? $this->db->escape_str($this->input->post('limit', TRUE)) : $this->config->item("length_records");
        $search = isset($_POST['query']) ? $this->db->escape_str($this->input->post('query', TRUE)) : '';

        $result = $this->mds->get_rows_twin($search, $start, $limit);
        echo $result;
    }
    
    
    public function update_rows()
    {
        $opt = isset($_POST['cmd']) ? $this->db->escape_str($this->input->post('cmd', TRUE)) : '';
        $nis=isset($_POST['nis']) ? $this->db->escape_str($this->input->post('nis', TRUE)) : '';
        $nama=isset($_POST['nama']) ? $this->db->escape_str($this->input->post('nama', TRUE)) : '';
        $ayah=isset($_POST['ayah']) ? $this->db->escape_str($this->input->post('ayah', TRUE)) : '';
        $ibu=isset($_POST['ibu']) ? $this->db->escape_str($this->input->post('ibu', TRUE)) : '';
        $alamat=isset($_POST['alamat']) ? $this->db->escape_str($this->input->post('alamat', TRUE)) : '';
        $telepon=isset($_POST['telepon']) ? $this->db->escape_str($this->input->post('telepon', TRUE)) : '';
        $seluler=isset($_POST['seluler']) ? $this->db->escape_str($this->input->post('seluler', TRUE)) : '';
        $tempat_lahir=isset($_POST['tempat_lahir']) ? $this->db->escape_str($this->input->post('tempat_lahir', TRUE)) : '';
        $tgl_lahir=isset($_POST['mtgl_lahir']) ? $this->db->escape_str($this->input->post('mtgl_lahir', TRUE)) : NULL;
        $th_masuk=isset($_POST['th_masuk']) ? $this->db->escape_str($this->input->post('th_masuk', TRUE)) : NULL;
        $th_alumni=isset($_POST['mth_alumni']) ? $this->db->escape_str($this->input->post('mth_alumni', TRUE)) : NULL;
        $jenis_kelamin=isset($_POST['jenis_kelamin']) ? $this->db->escape_str($this->input->post('jenis_kelamin', TRUE)) : '';
        $kd_kelas=isset($_POST['kd_kelas']) ? $this->db->escape_str($this->input->post('kd_kelas', TRUE)) : '';
        $tinggi=isset($_POST['tinggi']) ? $this->db->escape_str($this->input->post('tinggi', TRUE)) : NULL;
        $berat=isset($_POST['berat']) ? $this->db->escape_str($this->input->post('berat', TRUE)) : NULL;
        $id_user=$this->session->userdata('username');
        if(!$th_alumni)        {
            $th_alumni=NULL;
        }
        $param=array($opt,$nis,$nama,$ayah,$ibu,$alamat,$telepon,$seluler,$tempat_lahir,$tgl_lahir,$th_masuk,$th_alumni,$jenis_kelamin,$kd_kelas,$tinggi,$berat,$id_user);
        $spname='sp_siswa';
        $result = $this->mds->SP_execData($spname, $param, true);
        echo $result;        
    }
    
    public function delete_row()
    {
        $opt = isset($_POST['cmd']) ? $this->db->escape_str($this->input->post('cmd', TRUE)) : '';
        $data = isset($_POST['postdata']) ? json_decode($this->input->post('postdata', TRUE)): array(); 
        $nis=$data->nis;
        $nama=$data->nama;
        $ayah=$data->ayah;
        $ibu=$data->ibu;
        $alamat=$data->alamat;
        $telepon=$data->telepon;
        $seluler=$data->seluler;
        $tempat_lahir=$data->tempat_lahir;
        $tgl_lahir=$data->tgl_lahir;
        $th_masuk=$data->th_masuk;
        $th_alumni=$data->th_alumni;
        $jenis_kelamin=$data->jenis_kelamin;
        $kd_kelas=$data->kd_kelas;
        $tinggi=$data->tinggi;
        $berat=$data->berat;
        $id_user=$data->id_user;
        
        
        $param=array($opt,$nis,$nama,$ayah,$ibu,$alamat,$telepon,$seluler,$tempat_lahir,$tgl_lahir,$th_masuk,$th_alumni,$jenis_kelamin,$kd_kelas,$tinggi,$berat,$id_user);
        $spname='sp_siswa';
        $result = $this->mds->SP_execData($spname, $param, true);
        echo $result;
        
    }
    
    
}

?>
